|
|
|
|
|
|
|
Now you're ready for the fun stuff. The next method is the one that actually creates the script. Add the code from Listing A.31 to the module. |
|
|
|
|
|
|
|
|
Listing A.31. Coding the CreateScript subroutine. |
|
|
|
|
|
|
|
|
Public Sub CreateScript()
'
' walk through database objects and produce text file
'
On Error Resume Next
'
Dim objTableDef As TableDef
Dim objIndex As Index
Dim objRelation As Relation
'
' add script header
cWrLine = WrScriptHeader(cDBName)
Print #nWrFile, cWrLine
'
' add database create code
cWrLine = WrCreateDB(cDBName)
Print #nWrFile, cWrLine
'
' add table create code
For Each objTableDef In objDB.TableDefs
cWrLine = WrCreateTable(objTableDef)
If Len(cWrLine) > 0 Then
Print #nWrFile, cWrLine
End If
'
For Each objIndex In objTableDef.Indexes
cWrLine = WrCreateIndex(objIndex, objTableDef.Name)
If Len(cWrLine) > 0 Then
Print #nWrFile, cWrLine
End If
Next
Next
'
' add relation create code
For Each objRelation In objDB.Relations
cWrLine = wrCreateRelation(objRelation)
If Len(cWrLine) > 0 Then
Print #nWrFile, cWrLine
End If
Next
'
' add script footer
cWrLine = WrScriptFooter
Print #nWrFile, cWrLine
'
SQLVBMain.lblProgress = ""
End Sub |
|
|
|
|
|